Virt Tools
2013/12/30 |
Install useful tools for virt management.
|
|
[1] | Install virt tools. |
[root@dlp ~]# yum -y install libguestfs-tools virt-top
|
[2] | "ls" a directory in a virtual machine |
[root@dlp ~]# virt-ls -l -d www /root total 40 dr-xr-x---. 3 root root 4096 Jan 1 17:44 . dr-xr-xr-x. 18 root root 4096 Jan 1 17:40 .. -rw-------. 1 root root 16 Jan 1 17:44 .bash_history -rw-r--r--. 1 root root 18 Dec 4 21:14 .bash_logout -rw-r--r--. 1 root root 176 Dec 4 21:14 .bash_profile -rw-r--r--. 1 root root 176 Dec 4 21:14 .bashrc -rw-r--r--. 1 root root 100 Dec 4 21:14 .cshrc drwxr-xr-x. 3 root root 4096 Jan 1 17:44 .local -rw-r--r--. 1 root root 129 Dec 4 21:14 .tcshrc -rw-------. 1 root root 1029 Jan 1 17:41 anaconda-ks.cfg |
[3] | "cat" a file in a virtual machine |
[root@dlp ~]# virt-cat -d www /etc/passwd root:x:0:0:root:/root:/bin/bash bin:x:1:1:bin:/bin:/sbin/nologin daemon:x:2:2:daemon:/sbin:/sbin/nologin adm:x:3:4:adm:/var/adm:/sbin/nologin lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin sync:x:5:0:sync:/sbin:/bin/sync ... |
[4] | Edit a file in a virtual machine |
[root@dlp ~]# virt-edit -d www /etc/fstab # # /etc/fstab # Created by anaconda on Wed Jan 1 08:36:48 2014 # # Accessible filesystems, by reference, are maintained under '/dev/disk' # See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info # /dev/mapper/fedora-root / ext4 defaults 1 1 UUID=0e579832-238d-4d2b-b96f-8fa5a89bbe78 /boot ext4 defaults 1 2 /dev/mapper/fedora-swap swap swap defaults 0 0 |
[5] | Display disk usage in a virtual machine |
[root@dlp ~]# virt-df -d www Filesystem 1K-blocks Used Available Use% www:/dev/sda1 487652 65353 392603 14% www:/dev/sdora/root 28244124 713704 26072656 3% |
[6] | Mount a disk for a virtual machine |
[root@dlp ~]# guestmount -d www -i /media [root@dlp ~]# ll /media total 74 lrwxrwxrwx. 1 root root 7 Jan 1 17:37 bin -> usr/bin dr-xr-xr-x. 4 root root 1024 Jan 1 17:41 boot drwxr-xr-x. 2 root root 4096 Jan 1 17:36 dev drwxr-xr-x. 72 root root 4096 Jan 1 17:44 etc drwxr-xr-x. 3 root root 4096 Jan 1 17:40 home ... |
[7] | Display the status of virtual machines |
[root@dlp ~]# virt-top virt-top 18:54:49 - x86_64 6/6CPU 2801MHz 12137MB 3 domains, 2 active, 2 running, 0 sleeping, 0 paused, 1 inactive D:0 O:0 X:0 CPU: 0.0% Mem: 4596 MB (4596 MB by guests) ID S RDRQ WRRQ RXBY TXBY %CPU %MEM TIME NAME 19 R 0 0 0 0 0.0 8.0 0:12.86 www - (template) - (win7) |